#include "../../common/util.hpp"
#include "../../client/rpc_client.hpp"

void callback(const Json::Value &result) {
    LOG(INFO) << "callback result: " << result.asInt() << "\n";
}

int main()
{
    yssrpc::client::RpcClient client(true, "127.0.0.1", 8080);

    Json::Value params, result;
    params["num1"] = 11;
    params["num2"] = 22;
    bool ret = client.call("Add", params, result);
    if (ret != false) {
        LOG(INFO) << "result: " << result.asInt() << "\n";
    }

    yssrpc::client::RpcCaller::JsonAsyncResponse res_future;
    params["num1"] = 33;
    params["num2"] = 44;
    ret = client.call("Add", params, res_future);
    if (ret != false) {
        result = res_future.get();
        LOG(INFO) << "result: " << result.asInt() << "\n";
    }

    params["num1"] = 55;
    params["num2"] = 66;
    ret = client.call("Add", params, callback);
    LOG(DEBUG) << "-------------" << "\n";
    std::this_thread::sleep_for(std::chrono::seconds(1));
    return 0;
}